package single

import (
	"github.com/go-redis/redis"
	"time"
)

type OptFunc func(opts *redis.Options)

func SetPassword(val string) OptFunc {
	return func(opts *redis.Options) {
		opts.Password = val
	}
}

func SetDB(val int) OptFunc {
	return func(opts *redis.Options) {
		opts.DB = val
	}
}

func SetMaxRetries(val int) OptFunc {
	return func(opts *redis.Options) {
		opts.MaxRetries = val
	}
}

func SetReadTimeout(val time.Duration) OptFunc {
	return func(opts *redis.Options) {
		opts.ReadTimeout = val
	}
}

func SetWriteTimeout(val time.Duration) OptFunc {
	return func(opts *redis.Options) {
		opts.WriteTimeout = val
	}
}

func SetPoolSize(val int) OptFunc {
	return func(opts *redis.Options) {
		opts.PoolSize = val
	}
}

func SetMinIdleConns(val int) OptFunc {
	return func(opts *redis.Options) {
		opts.MinIdleConns = val
	}
}

func SetMaxConnAge(val time.Duration) OptFunc {
	return func(opts *redis.Options) {
		opts.MaxConnAge = val
	}
}

func SetPoolTimeout(val time.Duration) OptFunc {
	return func(opts *redis.Options) {
		opts.PoolTimeout = val
	}
}

func SetIdleTimeout(val time.Duration) OptFunc {
	return func(opts *redis.Options) {
		opts.IdleTimeout = val
	}
}
